package com.ego.coupon.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ego.coupon.po.HomeAdv;
import com.ego.coupon.service.HomeAdvService;
import com.ego.common.util.Result;

/**
 * @program: ego
 * @description 首页轮播广告控制器
 * @author KamTang
 * @date 2022-11-13 13:17:12
 */
@RestController
@RequestMapping("coupon/homeadv")
public class HomeAdvController {

    @Autowired
    private HomeAdvService homeAdvService;

    /**
     * 信息
     */
    @GetMapping("/get/{id}")
    public Result get(@PathVariable("id") Long id){
		HomeAdv homeAdv = homeAdvService.getById(id);
        return Result.ok().put("homeAdv", homeAdv);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody HomeAdv homeAdv){
		homeAdvService.save(homeAdv);
        return Result.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public Result update(@RequestBody HomeAdv homeAdv){
		homeAdvService.updateById(homeAdv);
        return Result.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody Long[] ids){
		homeAdvService.removeByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
